<%@ page import="com.example.rk.entity.Admin" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>XXXX后端管理系统</title>
    <jsp:include page="../common_css.jsp"/>

    <style>
        .form-control{
            width: 30%;
        }
    </style>
</head>
<body>
<div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <jsp:include page="../top.jsp"/>

    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
        <!-- partial:partials/_sidebar.html -->
        <jsp:include page="../gly/left.jsp"/>
        <!-- partial -->
        <div class="main-panel">
            <div class="row">
                <div class="col-md-12 stretch-card">
                    <div class="card">
                        <div class="card-body">

                            <div class="table-responsive" align="center">


                                <form id="frm" class="form-signin">
                                    <h1 class="h3 mb-3 font-weight-normal">添加数据</h1>

                                    <label for="inputname" class="sr-only">名称</label>
                                    <input type="text" id="inputname"  name="name" class="form-control" placeholder="名称" >
                                     <label for="inputdizhi" class="sr-only">地址</label>
                                    <input type="text" id="inputdizhi"  name="dizhi" class="form-control" placeholder="地址" >
                                    <label for="inputfaren" class="sr-only">法人姓名</label>
                                    <input type="text" id="inputfaren" name="faren" class="form-control" placeholder="法人姓名" >
                                    <label for="inputphone" class="sr-only">联系方式</label>
                                    <input type="text" id="inputphone" name="phone"   class="form-control" placeholder="联系方式" >
                                    <button class="btn btn-lg btn-primary btn-block" type="button" onclick="doAdd()" style="width: 30%">发出申请</button>
                                </form>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <jsp:include page="../footer.jsp"/>
    </div>
    <!-- main-panel ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<jsp:include page="../common_js.jsp"/>
</body>

</html>

<script>
    function doAdd() {
        //推荐前端js验证字段

        var inputname=$("#inputname").val();
        var inputphone=$("#inputphone").val();
        var inputfaren=$("#inputfaren").val();
        var inputdizhi=$("#inputdihzi").val();
        var inputtupian=$("#inputtupian").val()
        alert(inputtupian);
        if (inputname==''|| inputphone==''||inputfaren==''|| inputdizhi==''||inputtupian==''||inputtupian==undefined){
            alert("都不能为空");
        }else{
            $.ajax(
                {
                    type:"post",
                    url:"/company/add",
                    data:$("#frm").serialize(),
                    async:false,  //使用ajax同步提交数据
                    success:function (response) {
                            alert("申请成功跳转主页请等待管理员审核");
                        setTimeout(window.location.href="/admin/main",1000);
                        }
                }
            );
        }
    }
</script>


